<?php
/**
 * Nad�b (Mak�-Nad�b)
 *
 * @filesource 
 * @copyright  Copyright 2010 mateusweb.com.br
 * @license    Freeware
 * @package    Nadeb_Data
 * @subpackage Nadeb.Data.Insert
 * @version    1.0
 */


class Nadeb_Data_Update extends Nadeb_Data_InfoTable
{
	public function __construct($_module,$_file,$_formPost)
	{
		parent::__construct( $_module,$_file );
		
		$data = new Nadeb_Data_Forms($_module,$_file);
		$data->set_exceptions( "submit" );
		$data->set_exceptions( "id" );
		$data->set_updateAction();
		$data->set_formPost( $_formPost );
		
		if( $data->get_post() );
		{
			$db = Zend_Registry::get("db");
			$wh = $db->quoteInto( $this->table["key"].'=?', $_formPost["id"] );
			
			if( $db->update( $this->table["name"],$data->get_post(),$wh ) )
			{
				$this->id     = $_formPost["id"];
				$this->result = "Dados alterados com sucesso";
				return true;
			}
	    	else
	    	{
	    		$this->id     = false;
	    		$this->result = "Erro ao alterar dados!";
	    		return false;
	    	}
		}
		
		return false;
	}
	
	public function get_insertID()
	{
		return $this->id;
	}
	
	public function get_result()
	{
		return $this->result;
	}
}
